package tcp;

import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class chatservertcp {
	public static void main(String[] args) throws Exception{
		ServerSocket svr=null;
		try{
			svr=new ServerSocket(8888);
			System.out.println("dang lang nghe...");
			
			Socket soc=svr.accept();
			Scanner input=new Scanner(soc.getInputStream());
			String request=input.nextLine();
			String response="From server: "+request.toUpperCase();
			PrintWriter out=new PrintWriter(soc.getOutputStream(),true);
			out.println(response);
			input.close();
		}
		catch(Exception e){
			e.getStackTrace();
		}
		finally{
			if(svr!=null)svr.close();
		}
	}
}
